package router

import (
	"project/admin/controller/images"
	"project/admin/controller/login"
	"project/apis/web"
	"project/middleware"

	"github.com/gin-gonic/gin"
)

func RegisterRouter() *gin.Engine {
	r := gin.Default()

	api := r.Group("/api")
	{
		api.GET("ping", web.Ping)
		v1 := api.Group("/v1")
		v1.POST("login", web.Login)
		v1.Use(middleware.SignCheck())
		{
			v1.GET("test", web.Test)
		}
	}

	r.LoadHTMLGlob("admin/templates/**/*")
	admin := r.Group("/admin")
	{
		v3 := admin.Group("/login", middleware.Session("admin-web"))
		{
			v3.GET("captcha", login.CreateCaptcha)
		}

		admin.GET("login/index", login.Index)
		admin.GET("image/gif", images.ImageGif)
	}

	return r
}
